package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.HqInventory;
import com.drug.mingkang.Mapper.HqInventoryMapper;
import com.drug.mingkang.service.HqInventoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 总公司库存表(HqInventory)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:42
 */
@Service("hqInventoryService")
public class HqInventoryServiceImpl implements HqInventoryService {
    @Resource
    private HqInventoryMapper hqInventoryMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param inventoryId 主键
     * @return 实例对象
     */
    @Override
    public HqInventory queryById(String inventoryId) {
        return this.hqInventoryMapper.queryById(inventoryId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<HqInventory> queryAllByLimit(int offset, int limit) {
        return this.hqInventoryMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param hqInventory 实例对象
     * @return 实例对象
     */
    @Override
    public HqInventory insert(HqInventory hqInventory) {
        this.hqInventoryMapper.insert(hqInventory);
        return hqInventory;
    }

    /**
     * 修改数据
     *
     * @param hqInventory 实例对象
     * @return 实例对象
     */
    @Override
    public HqInventory update(HqInventory hqInventory) {
        this.hqInventoryMapper.update(hqInventory);
        return this.queryById(hqInventory.getInventoryId());
    }

    /**
     * 通过主键删除数据
     *
     * @param inventoryId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String inventoryId) {
        return this.hqInventoryMapper.deleteById(inventoryId) > 0;
    }
}